﻿using System;
using System.Windows.Controls;
using MDCAdminTool.Reports;

namespace MDCAdminTool.Commands
{
    public abstract class AddCartTabCommandBinding : AddTabCommandBindingBase
    {
        protected virtual void AddNewTab( string header , Type chartType , params Object[] args )
        {
            if ( InitTabControl() == null ) return;

            try
            {
                TabControl.Dispatcher.Invoke(
                    new Action(
                        () =>
                            {
                                var chart  = Activator.CreateInstance( chartType , args );
                                AddNewTab( new HeaderChart { Title = header } , chart );
                            }
                        ) );
            }
            catch { }
        }
    }
}